#pragma once
#include <esp_err.h>
#include "esp_timer.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

#define DELAY_MS(ms) vTaskDelay(ms / portTICK_PERIOD_MS)

#define MEASURE_FUNC(func)                                                          \
    do                                                                              \
    {                                                                               \
        int64_t start_time = esp_timer_get_time();                                  \
        esp_err_t err = func;                                                       \
        int64_t end_time = esp_timer_get_time();                                    \
        ESP_LOGI(TAG, "%s took %llds %lldms %lldus", #func,                         \
                 (end_time - start_time) / 1000000,                                 \
                 (end_time - start_time) / 1000 % 1000,                             \
                 (end_time - start_time) % 1000);                                   \
        if (err != ESP_OK)                                                          \
        {                                                                           \
            ESP_LOGE(TAG, "%s failed with error: %s", #func, esp_err_to_name(err)); \
        }                                                                           \
    } while (0)

// void app_wifi_init();
esp_err_t mount_storage(const char *base_path);
esp_err_t start_file_server(const char *base_path);
